package com.he.combinationmodel.leaf;

import com.he.combinationmodel.compoent.Compoent;

/**
 * 组合模式的树叶节点，没有子节点，因此不含新增和删除方法逻辑
 */
public class Leaf extends Compoent {

    private String name;


    public Leaf(String name) {
        super(name);
        this.name = name;
    }

    @Override
    public void add(Compoent compoent) {
    }

    @Override
    public void remove(Compoent compoent) {

    }

    @Override
    public void display(int depth) {
        for (int i = 0; i < depth; i++) {
            System.out.printf("-");
        }
        System.out.printf(name);
        System.out.println();
    }
}

